<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #box {
            width: 300px;
            border-bottom: 1px solid #ccc;
            margin: 100px auto;
            position: relative;
        }
        
        img {
            width: 24px;
            position: absolute;
            top: 5px;
            right: 5px;
        }
        
        input {
            padding: 0;
            height: 30px;
            width: 260px;
            border: none;
            outline: none;
        }
    </style>
</head>

<body>
    <div id="box">
        <label for=""><img src="images/close.png" alt="" id="eye"></label>
        <input type="text" name="" id="pwd">
    </div>
    <script>
        var input = document.getElementById('pwd')
        var eye = document.getElementById('eye')
        eye.onclick = function() {
            if ('text' === input.type) {
                input.type = 'password'
                this.src = 'images/close.png'
            } else {
                input.type = 'text'
                this.src = 'images/open.png'
            }
        }
    </script>

</body>

</html>